<html>
    <head>
        <title>Simple</title>
        <link type="text/css" rel="Stylesheet" href="jquery.validity.css" />
        <script type="text/javascript" src="../jQuery.validity/jquery.js"></script>
        <script type="text/javascript" src="../jQuery.validity/jquery.validity.js"></script>
        <script type="text/javascript">
			var 
                log = [],
                currentTest = '';
            
            function expect(n, r) {
                var selector;
                
                if (r.errors != n) {
                    log.push("Test: " + currentTest + "  failed. Expected: " + n + " Found: " + r.errors);
                }
            }
            
			var tests = {};
			
            $(function() { 
                perform();
            });
            
            function perform() {
				$("#testArea").show();
                
                if (confirm("Do tests?")) {
                
                    var halting = confirm("Halt on test completion?");
                    
                    for (var test in tests) {
                        for(var om in $.validity.outputs) {
                            currentTest = test + " " + om;
                            
                            $.validity.clear();
                            
                            $.validity.setup({outputMode:om});
                            
                            $('input').val('');
                            
                            tests[test]();
                            
                            if (halting) {
                                halting = confirm("Halted. Continue tests with halting?");
                            }
                        }
                    }
                }
                
                if (log.length) {
                    $("body").html("<h1 style='color:#f00;'>Fail: Some tests failed.</h1><ul/>");
                    
                    for (var idx = 0; idx < log.length; idx++) {
                        $("<li>")
                            .text(log[idx])
                            .appendTo("ul");
                    }
                    
                    $("<a href='javascript:location.reload();'>Go again</a>")
                        .appendTo("body");
                }
                
                else {
                    $("body").html("<h1 style='color:#0f0;'>All tests succeeded.</h1><a href='javascript:location.reload();'>Go again</a>");
                }
            }
        </script>
        <script type="text/javascript" src="unittests.js"></script>
    </head>
    <body>
        <div id="testArea" style="display:none;">
            <div class="validity-summary-container">
              Summary:
              <ul></ul>
            </div>
            <input type="text" name="i0" id="i0" /><br />
            <input type="text" name="i1" id="i1" /><br />
            <input type="text" name="i2" id="i2" /><br />
            <input type="text" name="i3" id="i3" /><br />
            <input type="text" name="i4" id="i4" /><br />
            <input type="text" name="i5" id="i5" /><br />
            <input type="text" name="i6" id="i6" /><br />
            <input type="text" name="i7" id="i7" /><br />
            <div class="validity-summary-container">
              Summary:
              <ul></ul>
            </div>
        </div>
    </body>
</html>
